package com.lsf.studentmanagerup.dao;

import com.lsf.studentmanagerup.bean.User;
import com.lsf.studentmanagerup.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * @author 李树飞
 */
public class UserDaoImp implements UserDao {
    @Override
    public User userLogin(String username, String password) throws SQLException {
        //创建qr对象
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        //查找语句
        String sql = "select * from user where username = ? and password = ?";

        Object[] params = {username, password};
        //返回User对象
        return queryRunner.query(sql, new BeanHandler<>(User.class), params);
    }
}
